﻿// code03020300.cpp : 字符串
// 处理字符串中的字符

#include <iostream>
#include <cctype>
using namespace std;

int main()
{
    //统计标点符号个数
    string s("Hello World!!!");
    decltype(s.size()) punct_cnt = 0;//标点符号计数
    for (auto c: s)
    {
	    if (ispunct(c))
	    {
            ++punct_cnt;
	    }
    }
    cout << punct_cnt << " punctuation characters in " << s << endl;

    //转换大小写
    for (auto &c : s)
    {
        c = toupper(c);
    }
    cout << s << endl;



    //字符串局部处理
    decltype(s.size()) index=0;
    while (index!=s.size()&&!isspace(s[index]))
    {
        s[index] = tolower(s[index]);
        ++index;

    }
    cout << s << endl;

    return 0;

}

